Stage 2: ODBC pooling primitives (ADO #47338) - #296
Draft
Saurabh Singh (saurabh500) wants to merge 1 commit into
Draft
Conversation
Add SQL_ATTR_CONNECTION_DEAD and SQL_ATTR_RESET_CONNECTION support for connection pooling (Stage 2, ADO #47338). - B1: add SQL_ATTR_CONNECTION_DEAD/SQL_CD_TRUE/SQL_CD_FALSE and SQL_ATTR_RESET_CONNECTION/SQL_RESET_CONNECTION_YES constants. - B2: SQLGetConnectAttr(SQL_ATTR_CONNECTION_DEAD) returns a cached, never-probe liveness read; disconnected/never-connected reads DEAD. - B3: SQLSetConnectAttr(SQL_ATTR_RESET_CONNECTION) validates the value (HY024 otherwise), rolls back a live local transaction, arms the full RESETCONNECTION bit via prepare_reset_connection(false), and clears local_tran_started; disconnected surfaces 08003, busy is rejected. - Unit tests cover both attributes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 63e24621-7665-4572-a5b8-e5dfa55060a0
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 2 of the mssql-odbc connection pooling effort (
[AB#47338](https://sqlclientdrivers.visualstudio.com/b95cf060-8083-439d-8ef1-405d5bf219d8/_workitems/edit/47338)). Wires the two ODBC pooling attributes intomssql-odbc, building on the Stage 1 TDS reset/liveness primitives.B1 — Constants (
api/odbc_types.rs)SQL_ATTR_CONNECTION_DEAD = 1209,SQL_CD_TRUE = 1,SQL_CD_FALSE = 0SQL_ATTR_RESET_CONNECTION = 116,SQL_RESET_CONNECTION_YES = 1B2 —
SQLGetConnectAttr(SQL_ATTR_CONNECTION_DEAD)(api/get_connect_attr.rs)SQL_CD_FALSEonly when the DBC is connected andclient.is_connection_dead()is false; otherwiseSQL_CD_TRUE.SQL_CD_TRUE(D1: msodbcsql defaults DEAD until a successful token read).take()s it (D8).B3 —
SQLSetConnectAttr(SQL_ATTR_RESET_CONNECTION, YES)(api/set_connect_attr.rs+api/txn.rs)set_connect_attr.rsinto a newreset_connectionhandler intxn.rs.SQL_RESET_CONNECTION_YESaccepted; any other value ⇒ HY024.claim_dbc_client(busy/active_stmt⇒ connection-busy; disconnected ⇒ 08003, D7).prepare_reset_connection(false)(pool checkout does not preserve).state.local_tran_started. Never holds the DBC mutex across I/O.B7 (partial) — Tests
SQL_ATTR_CONNECTION_DEAD:SQL_CD_TRUEwhen disconnected / connected-without-client;SQL_CD_FALSEwhen connected-and-alive; null-pointer rejected.SQL_ATTR_RESET_CONNECTION: non-YES ⇒ HY024; disconnected ⇒ 08003; busy (active_stmt) rejected; success clearslocal_tran_startedand leaves the idle client in place.Validation
cargo bfmt✅cargo bclippy✅ (warnings-as-errors)cargo nextest run -p mssql-odbc✅ 573 passedStacking
This PR targets
saurabh500-stage-1-tds-reset-correctness, notmain. It is stacked on Stage 1 PR #294 (which stacks on base PR #293).[AB#47338](https://sqlclientdrivers.visualstudio.com/b95cf060-8083-439d-8ef1-405d5bf219d8/_workitems/edit/47338)